<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../css/登录.css"/>
		<script src="../js/jquery.min.js"></script>
	</head>
	<body>
		<div class="wrap">
			<div class="head">
				<div class="top">
					<img src="../img/login (1).jpg" alt="" />
					<span>已有帐号？<a href="../html/注册.html" style="color:#ff6600;">请登录</a></span>
				</div>
			</div>
			<div class="con">
		         <div class="conss">
		         	<img src="../img/登录12-23_02_02.jpg" alt="">
				</div>
		         <div class="cons">
		         		<div class="imgs">
		         			<img src="../img/login (2).jpg" alt="" />
		         		</div>
		         		<div class="qie">
		         			<span class="qie_left">使用普通方式登录</span>
		         			<span class="qie_right">手机动态密码登录</span>
		         		</div>
		         		<div class="putong">
		         			<div class="inp" id="inp">
			         			<img src="../img/denglu (3).jpg" alt="" />
			         			<input type="text" placeholder="请输入手机号码"/>
			         		</div>
			         		<div class="inp2" id="inp">
			         			<div class="inp2_left">
			         				<img src="../img/denglu (1).jpg" alt="" />
			         				<input type="text" placeholder="请输入手机验证码"/>
			         			</div>
			         			<div class="inp2_right">
			         				<p>获取验证码</p>
			         			</div>
			         		</div>
			         		
		         		</div>
		         		<div class="shouji">
		        
			         		<div class="inp" id="inp">
			         			<img src="../img/denglu (3).jpg" alt="" />
			         			<input type="text" id="phone" placeholder="请输入手机号码"/>
			         		</div>
			         		<div class="inp2" id="inp">
			         			<div class="inp2_left">
			         				<img src="../img/denglu (1).jpg" alt="" />
			         				<input id="num" type="text" id="password" placeholder="请输入手机验证码"/>
			         			</div>
			         			<div class="inp2_right" id="btn">
			         				<p>获取验证码</p>
			         			</div>
			         		</div>
			         		
			         		<div class="inp" id="inp">
			         			<img src="../img/denglu (5).jpg" alt="" />
			         			<input type="text" placeholder="请输入图片验证码"/>
			         			<img style="width:68px;height:25px" src="../img/login (5).jpg" alt="" />
			         			<a href="#" style="color:#0099ff;text-decoration: underline;">换一张</a>
			         		</div>
			         		<div class="qie">
			         			<span class="say1"><img class="dian" src="../img/denglu (6).jpg" alt="" /><a href="#" style="color: black;">记住用户名</a></span>
			         			<a href="#" class="say2">忘记密码</a>
			         		</div>
		         		</div>
			         	<div class="yan">
			         		<img src="../img/denglu (7).jpg" alt="" />
			         		<span class="ziti">验证码输入错误</span>
			         	</div>
			         	<div class="anniu">
			         		<a style="color:#ffffff;">登录</a>
			         	</div>
			         	
		         </div>
		       </div>
			<div class="foot">
				<p>广西讯丰数字资产管理有限公司 版权所有 桂|CP备14005382号</p>
			</div>
		</div>
		<script>
			$(function(){
//				切换普通登录,密码登录
				$(".qie_left").click(function(){
					$(".putong").css("display","block");
					$(".shouji").css("display","none");
					$(".qie_left").css({
						"padding-bottom":"5px",
  						"border-bottom":"2px solid #FF6600",
  						"color":"#ff6600"
					});
					$(".qie_right").css({
						"border-bottom":"none",
						"color":"#cccccc"
					})
				})
				$(".qie_right").click(function(){
					$(".putong").css("display","none");
					$(".shouji").css("display","block");
					$(".qie_right").css({
						"padding-bottom":"5px",
  						"border-bottom":"2px solid #FF6600",
  						"color":"#FF6600"
					});
					$(".qie_left").css({
						"border-bottom":"none",
						"color":"#cccccc"
					})
				})
				
//				记住用户名
					var toggle = true;
					$(".dian").click(function(){
						if(toggle){
							$(this).attr("src","../img/denglu (6).jpg");
							 toggle = false;
						}else{
							$(this).attr("src","../img/small_03.jpg");
							toggle = true;
						}	
						
					})
					
			

//				获取焦点inp变色
					$("#inp input").focus(function(){
						$(this).parent().css("border","1px solid #FF6600");
	
					}).blur(function(){
						$(this).parent().css("border","1px solid #cccccc");
					});
				
				
			
//				判断手机号码
					$("#phone").focus(function(){
						if($('#phone').val().length == 0) {
						  	$(".ziti").html("手机号没有输入")			 	
						} else if(!(/^1[34578]\d{9}$/.test($('#phone')))){
							$(".ziti").html("手机号码不正确")				   		
						  	
						}		
					})
						

				
				
		
//				获取验证码
					function rand(min,max) { 
						return Math.floor(Math.random()*(max-min))+min;   
					}     
					$("#btn").click(function(){     
						var randnum=rand(1000,9999); 
						$("#num").val(randnum);
					})

//               跨域
				function logIn(name,password){
				$.ajax({
					url:"https://web-gateway.newbeescm.com/b2b-app-web/user/login",
					data:{
						loginName:name,
						password:password
					}
				}).then(res=>{
//					localStorage.setItem("token",res.result.token);
//					localStorage.setItem("phone",res.result.phone);
//					window.location.href="../html/登录/html"
                    if(res.status.statusCode=1171500){
                    	window.location.href="首页.html"
                    }
					console.log(res);
				}).catch(rej=>{
					conosle.log(rej);
				})
			}
			
		  $(function(){
		  	$(".anniu").click(function(){
		  		var name=$("#phone").val();
		  		var password=$("#password").val();
		  		logIn(name,password);
		  	})
		  })
				
			})
		</script>
	</body>
</html>
